package com.mysher.devlib.uvc;

import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.graphics.YuvImage;

import java.io.ByteArrayOutputStream;

class Yuy2Utils {

    static byte[] yuy2ToJpeg(byte[] yuy2, int width, int height) {
        YuvImage yuvImage = new YuvImage(yuy2, ImageFormat.YUY2, width, height, null);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        yuvImage.compressToJpeg(new Rect(0, 0, width, height), 100, byteArrayOutputStream);
        return byteArrayOutputStream.toByteArray();
    }
}
